using NUnit.Framework;

using FineCollection.Intf;

namespace FineCollection.Common
{


    public abstract class RSet_Common_test
    {

        protected abstract RSet<long> MakeEmptySet();

        protected abstract RSet<long> MakeSet1();

        protected abstract RSet<long> MakeSet3();



        [Test]
        public void Test_Empty_Set_Basic()
        {
            RSet<long> s0 = MakeEmptySet();

            Assert.IsTrue(s0.IsEmpty);
            Assert.IsFalse(s0.IsNotEmpty);
            Assert.AreEqual(0, s0.Count);
        }


        [Test]
        public void Test_Empty_Set_Contains()
        {
            RSet<long> s0 = MakeEmptySet();

            Assert.IsFalse(s0.Contains(0));
            Assert.IsFalse(s0.Contains(+1));
            Assert.IsFalse(s0.Contains(-1));
            Assert.IsFalse(s0.Contains(long.MinValue));
            Assert.IsFalse(s0.Contains(long.MaxValue));
        }


        [Test]
        public void Test_Empty_Set_Iterator()
        {
            RSet<long> s0 = MakeEmptySet();
            RIterator<long> it = s0.TakeIterator();

            Assert.IsFalse(it.Next());
        }


        [Test]
        public void Test_Set_1_Basic()
        {
            RSet<long> s1 = MakeSet1();

            Assert.IsFalse(s1.IsEmpty);
            Assert.IsTrue(s1.IsNotEmpty);
            Assert.AreEqual(1, s1.Count);
        }


        [Test]
        public void Test_Set_1_Contains()
        {
            RSet<long> s1 = MakeSet1();

            Assert.IsFalse(s1.Contains(0));
            Assert.IsTrue (s1.Contains(1111));
            Assert.IsFalse(s1.Contains(long.MinValue));
            Assert.IsFalse(s1.Contains(long.MaxValue));
        }


        [Test]
        public void Test_Set_1_Iterator()
        {
            RSet<long> s1 = MakeSet1();
            RIterator<long> it = s1.TakeIterator();

            Assert.IsTrue( it.Next() );
            Assert.AreEqual(1111, it.Current);
            Assert.IsFalse(it.Next());
        }


        [Test]
        public void Test_Set_3_Basic()
        {
            RSet<long> s3 = MakeSet3();

            Assert.IsFalse(s3.IsEmpty);
            Assert.IsTrue(s3.IsNotEmpty);
            Assert.AreEqual(3, s3.Count);
        }


        [Test]
        public void Test_Set_3_Contains()
        {
            RSet<long> s3 = MakeSet3();

            Assert.IsFalse(s3.Contains(-1));
            Assert.IsTrue (s3.Contains(1111));
            Assert.IsTrue (s3.Contains(2222));
            Assert.IsTrue (s3.Contains(3333));
        }


        [Test]
        public void Test_Set_3_Iterator()
        {
            RSet<long> s3 = MakeSet3();
            RIterator<long> it = s3.TakeIterator();

            Assert.IsTrue( it.Next() );
            Assert.AreEqual(1111, it.Current);
            Assert.IsTrue( it.Next() );
            Assert.AreEqual(2222, it.Current);
            Assert.IsTrue( it.Next() );
            Assert.AreEqual(3333, it.Current);
            Assert.IsFalse(it.Next());
        }

    }


}